home *** CD-ROM | disk | FTP | other *** search
/ QuickTime 2.0 Developer Kit / QuickTime 2.0 Developer Kit.iso / mac / MAC / Programming Stuff / Sample Code / Music Architecture / Mixed Bag / •Instrument Editor / Instrument Editor.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-10-06  |  4.9 KB  |  238 lines  |  [TEXT/KAHL]

  1. /*
  2.  * file: Instrument Editor.h
  3.  *
  4.  * started 12 January 1992 16:45
  5.  * david van brink
  6.  *
  7.  * A starting point for BigEasy programs
  8.  *
  9.  */
  10.  
  11. #ifndef _InstrumentEditor_
  12. #define _InstrumentEditor_
  13.  
  14. /*--------------------------
  15.     Inclusions
  16. --------------------------*/
  17.  
  18.  #include <Files.h>
  19.  #include <Windows.h>
  20.  #include <Lists.h>
  21.  
  22. #include "BigEasyControls.h"
  23. #include <QuickTimeComponents.h>
  24. //#include "NoteAllocatorComponent.h"
  25. #include "IE KeyboardDiagram.h"
  26.  
  27. /*--------------------------
  28.     Structures
  29. --------------------------*/
  30. #define kDocMargin 9
  31. #define kHeaderHeight 17
  32. #define kSliderWidth 150
  33. #define kInstrumentListWidth 127
  34. #define kInstrumentListCellHeight 13
  35. #define kTextAllowance 12
  36.  
  37. #define kStatLineCount 4
  38. #define kStatHeight (kTextAllowance * kStatLineCount + 6)
  39. #define kStatTop (kHeaderHeight+kDocMargin)
  40. #define kStatBottom (kStatTop+kStatHeight)
  41. #define kStatLeft kDocMargin
  42. #define kStatRight (kStatLeft+kInstrumentListWidth)
  43.  
  44. #define kKeyboardTop (kStatBottom+kDocMargin)
  45. #define kKeyboardBottom (kKeyboardTop+0x1F)
  46. #define kKeyboardLeft kDocMargin
  47.  
  48. #define kKeyboardOctaveCount (kInstrumentListWidth/63)
  49. #define kKeyboardRight (kKeyboardLeft+kKeyboardOctaveCount*63+1)
  50.  
  51. #define kInstrumentListTop (kKeyboardBottom+kDocMargin)
  52. #define kInstrumentListLeft (kStatLeft)
  53. #define kInstrumentListRight (kStatRight)
  54.  
  55. #define kSliderzoneLeft (2*kDocMargin+kInstrumentListWidth)
  56.  
  57. #define kMaxInstruments 256
  58.  
  59. enum
  60.     {
  61.     mNew = 100,
  62.     mOpen,
  63.     mCPULoad,
  64.  
  65.     mFirstDocOnly,
  66.     mClose,
  67.     mSave,
  68.     mSaveAs,
  69.     mGetInstrument,
  70.     mSetInstrument,
  71.     mNameInstrument,
  72.     mRandomizeKnobs,
  73.  
  74.     mGlobalKnobs,            /* also used as tag for which to display of 3 */
  75.     mInstrumentKnobs,
  76.     mControllers,
  77.  
  78.  
  79.  
  80.     mPitchbendDoc,
  81.     mMicrotoneDoc,
  82.     mTestDoc,
  83.  
  84.     mLastDocOnly
  85.     };
  86.  
  87.  
  88. typedef struct
  89.     {
  90.     OSType synthType;
  91.     Str31 synthName;
  92.     } SynthMenuEntry;
  93.  
  94. typedef struct
  95.     {
  96.     short synthCount;
  97.     SynthMenuEntry entry[1];
  98.     } SynthList, **SynthListHandle;
  99.  
  100.  
  101.  
  102. #define kDocVersion 1
  103. typedef struct
  104.     {
  105.     OSType synthType;
  106.     Str31 synthName;
  107.     } TPartialSaveRecord;
  108.  
  109.  
  110.  
  111. typedef struct
  112.     {
  113.     Boolean used;
  114.  
  115.     Boolean everSaved;
  116.     Boolean changed;
  117.     Boolean littleChanged;        /* Save available, but no "Save Discard?" on close */
  118.  
  119.     FSSpec docSpec;
  120.     TPartialSaveRecord sr;
  121.  
  122.     WindowPtr w;
  123.  
  124. /*----*/
  125.     NoteAllocator na;
  126.  
  127.     EasyControlList ecl;
  128.     EasyControl *ec;
  129.  
  130.     short whichList;                        /* which knobs? from above enum */
  131.     short knobCount;
  132.     Str255 instrumentName;
  133.     MusicComponent ci;
  134.     long part;
  135.  
  136.     NoteChannel nc;
  137.  
  138.     SynthesizerDescription sd;
  139. //    long firstModifiableInstrument;
  140.     long globalKnobCount;
  141.     KnobDescription **gkdList;
  142.     long instrumentKnobCount;
  143.     KnobDescription **ikdList;
  144.     long controllerCount;
  145.  
  146.     ToneDescription td;
  147.     long stashInstrument;
  148.     long recallInstrument;
  149.  
  150.     Rect virtualSliderBounds;            /* 0,0 -> x,y, the virtual workspace */
  151.     Rect visibleSliderBounds;            /* x1,y1 -> x2,y2, the present visible part */
  152.     ControlHandle horizontalScroller;
  153.     ControlHandle verticalScroller;
  154.     long lastH, lastV;                    /* matches the scroller controls, it is
  155.                                          * the virtual coordinate of the topLeft of
  156.                                          * the visible bounds.
  157.                                          */
  158.  
  159.     ListHandle listH;
  160.     Rect statBounds;
  161.     short instrumentCount;
  162.     InstrumentDataHandle instrument[kMaxInstruments];
  163.  
  164.     unsigned char keyVel[128];                /* array for keyboard diagram drawing */
  165.     Boolean controllersDirty;
  166.  
  167.     KeyboardDiagram kd;
  168.     } TDoc;
  169.  
  170. typedef struct
  171.     {
  172.     long docVersion;            /* quick check that we can really open the file */
  173.     Rect windowRect;
  174.     TPartialSaveRecord sr;
  175.     } TSaveRecord;
  176.  
  177.  
  178.  
  179.  
  180.  
  181. /*--------------------------
  182.     Variables
  183. --------------------------*/
  184.  
  185. #ifdef globals
  186.     #define VAR
  187. #else
  188.     #define VAR extern
  189. #endif
  190.  
  191. #define kFirstDocWindow 1
  192. #define kDocMax 5
  193. VAR TDoc gDoc[kDocMax];
  194. VAR short gDocCount;
  195.  
  196. VAR SynthListHandle gSynthListH;
  197.  
  198. #undef VAR
  199.  
  200.  
  201. /*--------------------------
  202.     Prototypes
  203. --------------------------*/
  204.  
  205. void NewDocFromSaveRecord(short docNumber,TSaveRecord *sr,SynthMenuEntry *sme);
  206. void DrawDoc(short n);
  207. void ClickDoc(short n,Point p,short mods);
  208.  
  209. void ResizeDoc(short n, Point *oldSize, Point *newSize, short modifiers);
  210. void FlashResult(ComponentResult result);
  211.  
  212. void SetupSliderClipDoc(TDoc *d);
  213. void DoneSliderClipDoc(TDoc *d);
  214. void DrawStats(TDoc *d);
  215. void UpdateSliderKnobs(TDoc *d);
  216.  
  217. void MakeControlsFromKnobList(TDoc *d,Rect *outRect);
  218.  
  219. void FixUpMenus(TDoc *d);
  220. void FixForSize(TDoc *d);
  221.  
  222. SynthListHandle GetSynthesizerList(void);
  223.  
  224. void DoGlobalKnobs(short n, short menuItem, short menuRef);
  225. void DoInstrumentKnobs(short n, short menuItem, short menuRef);
  226. void DoControllers(short n, short menuItem, short menuRef);
  227.  
  228. void PitchBendDoc(short n, short menuItem, short menuRef);
  229. void MicrotoneDoc(short n, short menuItem, short menuRef);
  230. void NotesOnDoc(short n, short menuItem, short menuRef);
  231. void NotesOffDoc(short n, short menuItem, short menuRef);
  232. void SetInstrumentDoc(short n, short menuItem, short menuRef);
  233.  
  234. void SetInstrumentForDoc(TDoc *d,InstrumentDataHandle iH);
  235. void NewScrollDoc(TDoc *d,Boolean doScroll,RgnHandle updateRgn);
  236.  
  237. #endif _InstrumentEditor_
  238.